package com.baozhun.mall.common.adapter

import android.view.View
import com.baozhun.mall.common.BR
import com.baozhun.mall.common.R
import com.baozhun.mall.common.base.BaseListAdapter
import com.baozhun.mall.common.bindadapter.CustomBindAdapter
import com.baozhun.mall.common.databinding.ItemCommonGoodsBinding
import com.baozhun.mall.common.model.bean.GoodsInfoBean
import com.baozhun.mall.common.util.CacheUtil
import com.chad.library.adapter.base.listener.OnItemClickListener
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder

/**
 * @Title：通用渠道（一行两个）商品配置器
 * @Description：
 * @Author：xing.luo
 * @Since：2022/11/09
 * @Version：1.0.0
 */
class CommonGoodsChannelAdapter(data: MutableList<GoodsInfoBean>, private var onItemClickListener: OnItemClickListener? = null) :
    BaseListAdapter<GoodsInfoBean, ItemCommonGoodsBinding>(
        R.layout.item_common_goods, data
    ) {

    override fun convert(holder: BaseDataBindingHolder<ItemCommonGoodsBinding>, item: GoodsInfoBean) {
        holder.dataBinding?.setVariable(BR.model, item)
        holder.dataBinding?.contentView?.setOnClickListener {
            onItemClickListener?.onItemClick(this, holder.dataBinding?.contentView!!, holder.absoluteAdapterPosition)
        }
        holder.dataBinding?.executePendingBindings()
    }
}